#! /usr/bin/env python
import math
import sys

LIMIT=3000

def solvT(c):
    if not (math.sqrt(1+24*c)+1)%6:
        return (int(math.sqrt(1+24*c)+1))/6
    return None

def solvP(c):
    if not (math.sqrt(1+24*c)+1)%6:
        return (int(math.sqrt(1+24*c)+1))/6
    return None

def solvH(c):
    if not (math.sqrt(1+8*c)+1)%4:
        return (int(math.sqrt(1+8*c)+1))/4
    return None

def pent(n):
    return n*(3*n-1)/2

def main():
    global LIMIT
    if len(sys.argv)>1:
        LIMIT = int(sys.argv[1])
    for i in range(286,LIMIT):
        if solvP(i*(i+1)/2) and solvH(i*(i+1)/2):
            print i*(i+1)/2
if __name__ == '__main__':
    main()
    
